<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    allSettled方法用来确定异步操作是否都结束(不管成功还是失败都返回结果)
    包含fulfilled跟rejected两种情况
    <script>
        // 封装一个Ajax函数
        function Ajax(url){
            return new Promise((resolve,reject)=>{
                let xhr = new XMLHttpRequest()
                xhr.open()
                xhr.send()
                xhr.onreadystatechange = function(){
                    if(xhr.readyState === 4){
                        if(xhr.status >= 200 && xhr.status < 300){
                            resolve(xhr.responseText)
                        }else{
                            reject(xhr.responseText)
                        }
                    }
                }
            })
        }
        Promise.allSettled([
            Ajax('http://iwenwiki.com/api/blueberrypai/getchengpinInfo.php'),
            Ajax('http://iwenwiki.com/api/blueberrypai/getListeningInfo.php')
        ]).then(value => {
            console.log(value);
        })
    </script>
</body>
</html>